<?php

namespace Home\Controller;

class TuanController extends CommonController {

    public function lists() {
        $id = I('get.id', '0', 'int');
        if ($id > 0) {
            cookie("area", $id);
        }
        $sql = "(FIND_IN_SET('" . $id . "',circles) or circles =0) AND is_tel = 0 AND is_check = 1";
        $lists = M('shop')->where($sql)->select();    //计算总数
        foreach ($lists as $k => $v) {
            $lists[$k]['shopCla'] = getShopCla($v['business_time'], $v['weeks'], $v['is_busy']);
        }
        $this->assign("lists", $lists);

        $sql = "(FIND_IN_SET('" . $id . "',circles) or circles =0) AND is_tel = 1 AND is_check = 1";
        $lists2 = M('shop')->where($sql)->select();    //计算总数

        foreach ($lists2 as $k => $v) {
            $lists2[$k]['shopCla'] = getShopCla($v['business_time'], $v['weeks'], $v['is_busy']);
        }
        $says = M("say")->where("is_index = 1 AND pid = 0")->select();
        foreach ($says as $k => $v) {
            $says[$k]['sub'] = M("say")->where("is_index = 1 AND pid = " . $v['id'] . "")->find();
        }
        $this->assign("says", $says);
        $this->assign("lists2", $lists2);
        $this->assign("ctitle", getAreaName(0));
        $this->assign("adsIndexBanner", getTableFileLists('ads', 1));
        $this->assign("plays", getTableFile('play'));
        $config = getTableConfig();
        $this->display();
        if ($config['is_start_service'] > 0) {
            $services = getTableFile('service');
            foreach ($services as $v) {
                if ($v['pid'] == 0) {
                    $servicesArr[] = $v;
                }
            }
            foreach ($servicesArr as $k => $v) {
                foreach ($services as $k2 => $v2) {
                    if ($v2['pid'] == $v['id']) {
                        $servicesArr[$k]['sub'][$k2] = $v2;
                    }
                }
            }
            $this->assign("servicesArr", $servicesArr);
            $this->display("Service:" . $config['is_start_service'] . "");
        }
    }

}

?>
